import os
import json
# 1.exe打包的过程中，读取配置文件的方式
# 通过环境变量来获取 SafeMonitor目录的路径地址
root_path = os.getenv('Valkyrja_PATH')
real_root_path = os.path.abspath(root_path)
file = os.path.join(real_root_path, "app","static","configure","SmConfig.json")
# 2.开发模式下 读取文件。
# current_path = os.path.abspath(os.path.dirname(__file__))
# parent_path = os.path.abspath(os.path.dirname(current_path))
# app_path = os.path.abspath(os.path.dirname(parent_path))
# file = os.path.join(app_path, "static","configure","SmConfig.json")

with open(file, "r", encoding="utf-8") as f:
    sm_config = json.load(f)

LayerType = sm_config['LayerType']


ServiceType = sm_config['ServiceType']

default_MineId = sm_config['ServiceType']['Mine_Id']
default_MetaId = sm_config['ServiceType']['Meta_Id']

Sqlserver_Ip = sm_config['Sqlserver_Ip']
Sqlserver_Driver_Name = sm_config['Sqlserver_Driver_Name']
Sqlserver_Kj83_Database = sm_config['Sqlserver_Kj83_Database']
Sqlserver_Kj83_UserName = sm_config['Sqlserver_Kj83_UserName']
Sqlserver_Kj83_Pwd = sm_config['Sqlserver_Kj83_Pwd']
Sqlserver_dsn = "DRIVER={driver};SERVER={server};DATABASE={database};UID={username};PWD={pwd}".format(driver=Sqlserver_Driver_Name,server=Sqlserver_Ip,database=Sqlserver_Kj83_Database,username=Sqlserver_Kj83_UserName,pwd=Sqlserver_Kj83_Pwd)